#include <bits/stdc++.h>

# define INF 0x7fffffff;  // 无穷大
typedef long long ll;

using namespace std;

class Solution {
    unordered_map<int, int> window;

    int add(int a) {
        int res = window.size();
        if (window[a] == 0) res++;
        window[a]++;
        return res;
    }

    void clear() {
        window.clear();
    }

public:
    int medianOfUniquenessArray(vector<int>& nums) {
        const int n = nums.size();
        map<int, int> map;
        for (int i = 0; i < n; i++) {
            for (int j = i; j < n; ++j) {
                map[add(nums[j])]++;
            }
            clear();
        }
        int cnt = 0, all = n * (n + 1) /2;
        for (auto& [k, v] : map) {
            cnt += v;
            if(cnt * 2 >= all) {
                return k;
            }
        }
        return 0;
    }
};

int main() {
    Solution s;
    vector<int> data = {1,2,3};
    auto res = s.medianOfUniquenessArray(data);
    std::cout << res << std::endl;
    return 0;
}
